<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head th:replace="common/competition-common :: common_head(~{::link},~{::script})">
  <meta charset="utf-8">
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0" name="viewport">
  <meta content="" name="description">
  <meta content="" name="keywords">
  <!-- **********asset*************-->
  <!-- Favicons -->
  <link href="/assets/img/favicon.png" rel="icon">
  <link href="/assets/img/apple-touch-icon.png" rel="apple-touch-icon">
  <!-- Vendor CSS Files -->
  <link href="/assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  <link href="/assets/vendor/bootstrap-icons/bootstrap-icons.css" rel="stylesheet">
  <link href="/assets/vendor/boxicons/css/boxicons.min.css" rel="stylesheet">
  <link href="/assets/vendor/quill/quill.snow.css" rel="stylesheet">
  <link href="/assets/vendor/quill/quill.bubble.css" rel="stylesheet">
  <link href="/assets/vendor/remixicon/remixicon.css" rel="stylesheet">
  <link href="/assets/vendor/simple-datatables/style.css" rel="stylesheet">
  <!-- Template Main CSS File -->
  <link href="/assets/css/style.css" rel="stylesheet">
  <a class="back-to-top d-flex align-items-center justify-content-center" href="#"><i
          class="bi bi-arrow-up-short"></i></a>
  <!-- Vendor JS Files -->
  <script src="/assets/vendor/apexcharts/apexcharts.min.js"></script>
  <script src="/assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
  <script src="/assets/vendor/chart.js/chart.min.js"></script>
  <script src="/assets/vendor/echarts/echarts.min.js"></script>
  <script src="/assets/vendor/quill/quill.min.js"></script>
  <script src="/assets/vendor/simple-datatables/simple-datatables.js"></script>
  <script src="/assets/vendor/tinymce/tinymce.min.js"></script>
  <script src="/assets/vendor/php-email-form/validate.js"></script>
  <!-- Template Main JS File -->
  <script src="/assets/js/main.js"></script>

  <style>
    .member-list {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
    }
    .member-item {
      border: 1px solid #ccc;
      padding: 10px;
      border-radius: 10px;
      background-color: #f9f9f9;
      flex: 1 1 calc(33% - 20px);
      box-sizing: border-box;
    }
    .member-role {
      font-weight: bold;
    }
    .student-info {
      border: 1px solid #ccc;
      padding: 10px;
      margin-bottom: 10px;
      border-radius: 5px;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    .action-links {
      margin-top: 10px;
    }
    .action-links a {
      margin-right: 10px;
      color: #007bff;
      text-decoration: none;
    }

    .student-name, .student-id {
      margin: 0;
    }

    .float-right {
      float: right;
    }
  </style>
</head>
<body>
<div th:replace="common/competition-common::mall-header"></div>
<div th:replace="common/competition-common::competition-sidebar"></div>

<main id="main" class="main">
  <section class="section profile">
    <div class="row">
      <div class="col-xl-4">
        <div class="card">
          <div class="card-header">
            <h4 class="card-title">团队LOGO</h4>
          </div>
          <div class="card-body profile-card pt-4 d-flex flex-column align-items-center">
            <!-- 使用object-fit: cover来确保图片在正方形容器中保持其比例 -->
            <div class="profile-img-container">
              <img th:src="${teamLogoUrl}" alt="Team Logo" class="rounded-circle profile-img">
            </div>
          </div>
        </div>
      </div>
      <div class="col-xl-8">
        <div class="card">
          <div class="card-body pt-3">
            <div class="tab-pane fade show active profile-overview" id="team-info-edit">
              <!-- Team Edit Form -->
              <form action="/modifyteam" method="post">
                <div class="row mb-3">
                  <label for="teamName" class="col-md-4 col-lg-3 col-form-label">团队名称</label>
                  <div class="col-md-8 col-lg-9">
                    <div class="form-group row">
                      <div class="col-sm-12">
                        <input type="text" class="form-control" name="teamName" id="teamName" th:value="${tn}">
                      </div>
                    </div>
                    <label for="captainName" class="col-form-label mt-2">队长名称</label>
                    <div class="col-sm-12 mt-1">
                      <span class="form-control-plaintext" th:text="${tc} ?: '未知队长'"></span>
                    </div>
                  </div>
                </div>

                <input name="tid" th:value="${tid}" type="hidden"/>
                <div class="row mb-3">
                  <!-- 学生成员卡片 -->
                  <div class="col-md-12">
                    <div class="card">
                      <div class="card-header">
                        <h4 class="card-title">学生成员</h4>
                      </div>
                      <div class="card-body">
                        <div class="member-list" id="student-members">
                          <span th:each="s:${students}">
                            <span th:if="${tv != s.getUserid()}">
                          <div class="member-item">
                            <span class="member-role">学号：</span> <input name="students[]" type="text" class="form-control"  th:value="${s.getUserid()}"><br/>
                            <span class="member-role">姓名：</span> <span th:text="${s.getRealname()}">姓名</span>
                            <button class="btn btn-secondary float-right" onclick="removeInput(this)">删除</button>
                          </div></span>
                            </span>
                        </div>
                        <div class="action-links">
                          <button class="btn btn-sm btn-primary mt-2" onclick="addStudentInput()">添加学生成员</button>
                        </div>
                      </div>
                    </div>
                  </div>

                  <div class="row mb-3">
                    <!-- 指导教师卡片 -->
                    <div class="col-md-12">
                      <div class="card">
                        <div class="card-header">
                          <h4 class="card-title">指导教师</h4>
                        </div>
                        <div class="member-list">
                            <span class="member-role">教师号：</span> <span th:text="${teacherInfo.getUserid()}">教师号</span><br/>
                            <span class="member-role">姓名：</span> <span th:text="${teacherInfo.getRealname()}">姓名</span>
                        </div>
                      </div>
                    </div>
                  </div>
                  <div class="text-center">
                    <button  class="btn btn-primary" type = "submit">提交</button>
                  </div>
                </div>
              </form>
            </div>
          </div>
        </div>
      </div>
    </div>
    </div>
  </section>
</main><!-- End #main -->

<!-- ======= Footer ======= -->
<footer id="footer" class="footer">
  <div class="copyright">
    Copyright2024@杭州助你成才计算机信息学院
  </div>

  </div>
</footer><!-- End Footer -->
<script>
  function addStudentInput() {
    event.preventDefault();
    var studentMembersDiv = document.getElementById('student-members');
    var newInputGroup = document.createElement('div');
    newInputGroup.className = 'input-group mb-2';
    newInputGroup.innerHTML = '<div class="member-item"><span class="member-role">学号：</span> <input name="students[]" type="text" class="form-control"  th:value="${s.getUserid()}"><br/>\n' +
            '<button class="btn btn-secondary float-right" onclick="removeInput(this)">删除</button></div>';
    studentMembersDiv.appendChild(newInputGroup);
  }
  function removeInput(button) {
    event.preventDefault();
    button.parentElement.remove();
  }
</script>
</body>
</html>